﻿@model IEnumerable<Kavaa.Modules.PortailMedical.Entity.Utilisateur>

@{
    ViewBag.Title = "ComptesClinique";
    Layout = null;
}
@using System.Web.Optimization
@using BootstrapSupport
@using NavigationRoutes
<!DOCTYPE html>
@if(Session["user"]!= null)
    {
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>@ViewBag.Title</title>
       @*<meta name="viewport" content="width=device-width, initial-scale=1.0">*@
        <link href="@Styles.Url("~/content/css")" rel="stylesheet"/>
        <link href="@Styles.Url("~/Content/css-responsive")" rel="stylesheet" type="text/css" />
        @*@RenderSection("head", required: false)*@
        @Html.Partial("_html5shiv")
        @* favicons and touch icons go here *@
       @Scripts.Render("~/js")
       
        <script>

            $(function () {
                $("#submitbtn").click(function () {
                    $("#loading").fadeIn();
                    var opts = {
                        lines: 12, // The number of lines to draw
                        length: 7, // The length of each line
                        width: 4, // The line thickness
                        radius: 10, // The radius of the inner circle
                        color: '#000', // #rgb or #rrggbb
                        speed: 1, // Rounds per second
                        trail: 60, // Afterglow percentage
                        shadow: false, // Whether to render a shadow
                        hwaccel: false // Whether to use hardware acceleration
                    };
                    var target = document.getElementById('loading');
                    var spinner = new Spinner(opts).spin(target);
                });
            });

            $(document).ready(function () {
                $('#example').dataTable({
                    "sDom": "<'row'<'span4'l><'span4'f>r>t<'row'<'span4'i><'span4'p>>",
                    "sPaginationType": "bootstrap"
                });
            });

            ////////////////////////////////////////////////////////
            function ModifUser() {

                var elementselectionnee = new Array();
                var j = 0;
                var a = document.getElementsByName("selectedusers");
                for (i = 0; i < a.length ; i++) {
                    if (document.getElementsByName("selectedusers")[i].checked == true) {
                        elementselectionnee[j] = document.getElementsByName("selectedusers")[i];
                        j++;
                    }
                }
                if (j != 1) {
                    document.getElementById("popupBloquante").href = "#alert";
                    if (j == 0) {

                        document.getElementById("message").innerHTML = "Veuillez selectionner un élément pour le modifier !!!";

                    }
                    if (j > 1) {

                        document.getElementById("message").innerHTML = "Veuillez sélectionner un seul élément pour le modifier !!!";
                    }

                } else {
                    document.getElementById("popupBloquante").href = "#popup_Modification";

                    document.forms["modificatonForm"].elements["nom"].value = document.getElementById(elementselectionnee[0].value + " _nom").innerHTML;
                    document.forms["modificatonForm"].elements["prenom"].value = document.getElementById(elementselectionnee[0].value + " _prenom").innerHTML;
                    document.forms["modificatonForm"].elements["telephone"].value = document.getElementById(elementselectionnee[0].value + " _telephone").innerHTML;
                    document.forms["modificatonForm"].elements["fonction"].value = document.getElementById(elementselectionnee[0].value + " _fonction").innerHTML;
                    document.forms["modificatonForm"].elements["email"].value = document.getElementById(elementselectionnee[0].value + " _email").innerHTML;
                    document.forms["modificatonForm"].elements["idUtilisateur"].value = elementselectionnee[0].value;

                }


            }

            ////////////////////////////////////////////////////////

            function SuppUser() {

                var elementselectionnee = new Array();
                var j = 0;
                var a = document.getElementsByName("selectedusers");
                for (i = 0; i < a.length ; i++) {
                    if (document.getElementsByName("selectedusers")[i].checked == true) {
                        elementselectionnee[j] = document.getElementsByName("selectedusers")[i];
                        j++;
                    }
                }


                if (j == 0) {
                    document.getElementById("suppUserBtn").href = "#alert";
                    document.getElementById("message").innerHTML = "Veuillez selectionner un élément pour le supprimer !!!";

                }
                else {
                    document.getElementById("suppUserBtn").href = "#popup_Delete";
                    document.getElementById("msgSupp").innerHTML = "Voulez vous vraiment supprimer les utilisateurs sélectionnés ?  ";
                }


            }

            //**********************************************************
            //0 :état inactif 1:état actif
            var idrow;

            $(function () {

                $('.mytable tr td button').click(function () {
                    idrow = $(this).attr('id');

                    $.ajax({
                        url: '/Cabinet/ActiverCompte',//ça marche
                        async: false,
                        type: 'POST',
                        data: { iduser: idrow },
                        success: function () {
                            window.location.reload();
                        }
                    });
                });



            });
            $(function () {

                $('.mytable tr td input').click(function () {
                    idrow = $(this).attr('id');

                    $.ajax({
                        url: '/Cabinet/DesactiverCompte',//ça marche
                        async: false,
                        type: 'POST',
                        data: { iduser: idrow },
                        success: function () {
                            window.location.reload();
                        }
                    });
                });



            });


		</script>
         <style>
  
             
             .form-signin {
        
        padding: 19px 29px 29px;
        margin: 0 auto 20px;
        background-color: #fff;
        border: 1px solid #e5e5e5;
        -webkit-border-radius: 5px;
           -moz-border-radius: 5px;
                border-radius: 5px;
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
      }
              #loading
    {
        display:none;
        position:fixed;
        left:0;
        top:0;
        width:100%;
        height:100%;
        background:rgba(255,255,255,0.8);
        z-index:1000;
    }
  
    #loadingcontent
    {
        display:table;
        position:fixed;
        left:0;
        top:0;
        width:100%;
        height:100%;
    }
  
    #loadingspinner
    {
        display: table-cell;
        vertical-align:middle;
        width: 100%;
        text-align: center;
        font-size:larger;
        padding-top:80px;
    }
        </style>
        <style>
             .form-signin {
        
        padding: 19px 29px 29px;
        margin: 0 auto 20px;
        background-color: #fff;
        border: 1px solid #e5e5e5;
        -webkit-border-radius: 5px;
           -moz-border-radius: 5px;
                border-radius: 5px;
        -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
           -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
      }
        </style>
                                    <div class="container">
     @{
         
         
         var prenomuser = ((Kavaa.Modules.PortailMedical.Entity.Utilisateur)(Session["user"])).Prenom;
       var nomuser = ((Kavaa.Modules.PortailMedical.Entity.Utilisateur)(Session["user"])).Name;}
          <table class="container">
              <tr>
                  <td>
            <img src="/Content/images/mediciMaroc.png" /> </td>
                  <td class="pull-right">
                      <br />
            <p style="text-align:right"><i class=" icon-user"> </i>&nbsp; &nbsp; @prenomuser  @nomuser  &nbsp; &nbsp;  @Html.ActionLink("Se déconnecter","Deconnexion")&nbsp; &nbsp; </p>
               </td>
           
        
        </tr>
        </table>
                                  </div>
    </head>
   
    <body style="background-color:#eeeeee">
        <div class="navbar navbar-inverse navbar-fixed-top" >
           <div class="navbar-inner">
               @* <div class="container" >
                   
                    <a style="text-align:center" class="brand" href="#" title="change in _bootstrapLayout.basic.cshtml">Portail Médical</a>
                   
            </div>*@
                
        </div>       
            </div>
        <div class="container">
            @Html.Partial("_alerts")
            @Html.Partial("_validationSummary")

          
           
<div class="container" style="background-color:white">
     <div class="navbar">
  <div class="navbar-inner">
        <ul class="nav">
       <li> @Html.ActionLink("Accueil","AccueilClinique")</li>
      <li > @Html.ActionLink("Accréditations","Accreditations")</li>
      <li>@Html.ActionLink(" Réservations","Reservations")</li>
      <li>@Html.ActionLink("Gérer Ressources","GererRessources")</li>
      <li>@Html.ActionLink("Admission des patients","AdmissionPatient")</li>
      <li  class="active">@Html.ActionLink("Comptes Clinique","ComptesClinique")</li>
    </ul>
            <form class="navbar-search pull-right">
      <i class="icon-search"></i>
  <input type="text" class="search-query" placeholder="Recherche">
</form>
  </div>
</div>
    
    
      <!-- Example row of columns -->
   
<div class="container" style="width:80%;padding:30px 30px 30px 30px;font-size:16px;font-family:'Times New Roman'">
     <p>Ici vous pouvez gérer les comptes de vos uilisateurs : </p>
   <br />
     <div class="">
  <a href="#popup_Creation"   data-toggle="modal"><button class="btn btn-primary"  >Nouveau utilisateur</button></a>&nbsp;
   <a href="#popup2"  id="popupBloquante" data-toggle="modal"><button class="btn btn-primary" onclick="ModifUser()" >Modifier</button></a>&nbsp;
 <a href="#popup_Delete" id="suppUserBtn"  data-toggle="modal"> <button class="btn btn-primary"  onclick="SuppUser()">Supprimer</button></a>
</div>


    @*PopUp pour la création d'un nouveau utilisateur*@
 <div id="popup_Creation" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="popupLabel" aria-hidden="true" >
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h3 id="popupLabel2">Entrez les informations de l'utilisateur:</h3>
              </div>
                
                    @using (Html.BeginForm("CreerUser", "Clinique","Post")){
                            @Html.AntiForgeryToken()
                            @Html.ValidationSummary(true)
  
                     <div style="padding-left:35px">
                          @Html.Action("CreerUser","Cabinet")
                     </div>
      
                   <div class="modal-footer">
                   <button class="btn" data-dismiss="modal" aria-hidden="true">Annuler</button>
                   <button class="btn btn-primary" type="submit"> Créer</button>
                  </div>
   
                    } 
 </div>
   
    @*PopUp pour la modification d'un utilisateur*@
     <div id="popup_Modification" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="popupLabel" aria-hidden="true"  >
				          <div class="modal-header">
					        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					        <h3 id="popupLabel2">Modifier un utilisateur</h3>
				          </div>
                        <form id="modificatonForm" action = "UpdateUser" method="get">

                                    <div style="padding-left:35px">
                                        <input type="hidden" name="idUtilisateur" value="1" />
                                        <div> 
                                         <label>Nom</label>
                                            <input type="text" value="" name="nom" />
                                         </div>
                                         <div>
                                         <label>Prenom</label>
                                            <input type="text" value="" name="prenom" />
                                         </div>
                                        <div> 
                                         <label>Fonction</label>
                                            <input type="text" value="" name="fonction" />
                                         </div>
                                         <div>
                                         <label>Telephone</label>
                                            <input type="text" value="" name="telephone" />
                                         </div>
                                        <div>
                                         <label>Email</label>
                                            <input type="text" value="" name="email" />
                                         </div>
                                     </div>

                                         <div class="modal-footer">
							                 <button class="btn" data-dismiss="modal" aria-hidden="true">Annuler</button>
							                 <button class="btn btn-primary" type="submit" >Modifier</button>
							            </div>
                        </form>
                </div>

<div id="alert" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="popupLabel" aria-hidden="true"  >
				      <div class="modal-header">
					    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					    <h3 id="popupalert">Erreur bloquante</h3>
				      </div>
                      <div style="padding-left:35px">
                          <table>
                               <tr><th><br/></th></tr>
                               <tr><th><br/></th></tr>
                               <tr><th id="message"></th></tr>
                               <tr><th><br /></th></tr>
                               <tr><th><br/></th></tr>
                          </table>
                      </div>
                      <div class="modal-footer">
                           <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Retour</button>
                      </div>
                  </div>
@*Commentaire*@


@*   @using (Html.BeginForm("DeleteUtilisateur","Cabinet","Post"))
 {  
     
          *@<div id="popup_Delete" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="popupLabel" aria-hidden="true" >
               <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                
              </div>
              <br /><br />
              <div id="msgSupp" style="padding-left:10px" > </div>
              <br /><br />
               <div class="modal-footer">
           <button class="btn" data-dismiss="modal" aria-hidden="true">Annuler</button>
           <button class="btn btn-primary" type="submit" name="buttons" value="supprimer" > Supprimer</button>
         
            </div>
              </div> 
     <br />
    <br />

<table class="table table-striped table-bordered" id="example" >
     <thead>
         <tr></tr> 
        <tr></tr>  
    <tr>
        
        <th style="width:10px"> </th>
        <th style="color:#A80000">
           Nom
        </th>
        <th style="color:#A80000">
            @Html.DisplayNameFor(model => model.Prenom)
        </th>
        <th style="color:#A80000">
            @Html.DisplayNameFor(model => model.Fonction)
        </th>
         <th style="color:#A80000">
            @Html.DisplayNameFor(model => model.Telephone)
        </th>
        <th style="color:#A80000">
            @Html.DisplayNameFor(model => model.Email)
        </th>
          <th style="color:#A80000">
           Etat du compte
        </th>
         <th>
           
        </th>
    </tr>
         </thead>
<tbody  class="mytable">
@foreach (var item in Model)
{
    <tr  id=@item.Id>

         <td style="text-align:center; vertical-align:middle"> <input type="checkbox" value= @item.Id name="selectedusers"/></td>
      
        <td id="@item.Id _nom">
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td id="@item.Id _prenom">
            @Html.DisplayFor(modelItem => item.Prenom)
        </td>
        <td id="@item.Id _fonction">
            @Html.DisplayFor(modelItem => item.Fonction)
        </td>
        <td id="@item.Id _telephone">
            @Html.DisplayFor(modelItem => item.Telephone)
        </td>
        <td id="@item.Id _email">
            @Html.DisplayFor(modelItem => item.Email)
        </td>
        <td>
          @Html.DisplayFor(modelItem => item.Etat) 
        </td>
        <td>
             <button id=@item.Id   class="btn"
      
       style=" background-image: url(Content/images/glyphicons-halflings.png);background-color: hsl(145, 62%, 68%) !important;background-repeat: repeat-x; background-image: -khtml-gradient(linear, left top, left bottom, from(#cdf3dd), to(#7adfa4));
  background-image: -moz-linear-gradient(top, #cdf3dd, #7adfa4);
  background-image: -ms-linear-gradient(top, #cdf3dd, #7adfa4);
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #cdf3dd), color-stop(100%, #7adfa4));
  background-image: -webkit-linear-gradient(top, #cdf3dd, #7adfa4);
  background-image: -o-linear-gradient(top, #cdf3dd, #7adfa4);
  background-image: linear-gradient(#cdf3dd, #7adfa4);
  border-color: #7adfa4 #7adfa4 hsl(145, 62%, 63%);
  color: #333 !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.33);
  -webkit-font-smoothing: antialiased;"><i class="icon-white icon-ok"></i> Activer</button> &nbsp;&nbsp;&nbsp; <input id=@item.Id type="button" style=" background-color: hsl(0, 100%, 69%) !important;
  background-repeat: repeat-x;
  background-image: -khtml-gradient(linear, left top, left bottom, from(#ff9e9e), to(#ff6060));
  background-image: -moz-linear-gradient(top, #ff9e9e, #ff6060);
  background-image: -ms-linear-gradient(top, #ff9e9e, #ff6060);
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ff9e9e), color-stop(100%, #ff6060));
  background-image: -webkit-linear-gradient(top, #ff9e9e, #ff6060);
  background-image: -o-linear-gradient(top, #ff9e9e, #ff6060);
  background-image: linear-gradient(#ff9e9e, #ff6060);
  border-color: #ff6060 #ff6060 hsl(0, 100%, 66%);
  color: #333 !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.19);
  -webkit-font-smoothing: antialiased;
" name="button" id="desactiver"  class="btn"  value="x Désactiver" /> 
            
        </td>
       
    </tr>
}
</tbody>
</table>
       
       

@* }*@</div>    

   <div id="list"> </div>     


</div>

            <hr>
            <footer>
                <p>&copy; Kavaa @System.DateTime.Now.ToString("yyyy")</p>
            </footer> 
        </div>
         @Scripts.Render("~/js")
       @*  @RenderSection("Scripts", required: false)*@
    </body>
</html>


     }
else{
 
  <h5>  Pour pouvoir accéder à cette page veuillez vous connecter :  @Html.ActionLink("Se connecter","SignIn","test") </h5>

}